<?php
/**
 * Created by swagger_zxd.
 * User: zxd
 * Date: 2018/2/24
 * Time: 10:34
 */

namespace app\admin\model;



use think\Model;

class Platform extends Model{
    /**
     * 平台汇总明细
     * @param $begin
     * @param $end
     * @param $page
     * @return \think\response\Json
     */
    public function loadPlatformSummaryData($begin,$end,$page){
        $records='';
        try{
            $pdo=odbcLink();
            $sqlstr="exec Bg_SelTotalScoreList ".$begin.", ".$end.",".$page;
            $sth=$pdo->query($sqlstr);
            $i=1;
            do{
                $rowset=$sth->fetchAll(\PDO::FETCH_ASSOC);
                switch($i){
                    case 3:
                        $count=$rowset[0]['c'];
                        $pageinfo=['count'=>$count,'page'=>$page];
                        break;
                    case 4:
                        $czscore=$rowset[0]['czscore'];
                        $todaymoney=$rowset[0]['todaymoney'];
                        $xtsy=$rowset[0]['xtsy'];
                        $sendscore=$rowset[0]['sendscore'];
                        $sendprizes=$rowset[0]['sendprizes'];
                        $countinfo=['czscore'=>$czscore,'todayMoney'=>$todaymoney,'xtsy'=>$xtsy,'sendscore'=>$sendscore,'sendprizes'=>$sendprizes];
                        break;
                    case 5:
                        if(!empty($rowset)){
                            foreach ($rowset as $k=>$value) {
                                $records[$k]['serverid']=$rowset[$k]['ID'];     //id
                                $records[$k]['writeDate']=$rowset[$k]['writedate'];
                                $records[$k]['todayreg']=$rowset[$k]['todayreg'];
                                $records[$k]['todaymoney']=$rowset[$k]['todaymoney'];
                                $records[$k]['maxonline']=$rowset[$k]['maxonline'];
                                $records[$k]['totalscore']=$rowset[$k]['totalscore'];
                                $records[$k]['sendscore']=$rowset[$k]['sendscore'];
                                $records[$k]['czscore']=$rowset[$k]['czscore'];
                                $records[$k]['totalprizes']=$rowset[$k]['totalprizes'];
                                $records[$k]['sendprizes']=$rowset[$k]['sendprizes'];
                                $records[$k]['dhprizes']=$rowset[$k]['dhprizes'];
                                $records[$k]['xtsy']=$rowset[$k]['xtsy'];
                                $records[$k]['zsc']=$rowset[$k]['ZSC'];
                                $records[$k]['zsb']=$rowset[$k]['zsb'];
                            }
                        }
                        break;
                }

                $i++;
            }while($sth->nextRowset());
            $out=['pageInfo'=>$pageinfo,'countInfo'=>$countinfo,'records'=>$records];
            return json($out);
        }catch(\Exception $e){
            echo $e->getMessage();
        }
    }

    public function loaPlatformSummaryDetails(){
        $records="";
        try{
            $pdo=odbcLink();
            $sqlstr="exec Bg_SelScoreCountToday";
            $sth=$pdo->query($sqlstr);
            $i=1;
            do{
                $rowset=$sth->fetchAll(\PDO::FETCH_ASSOC);
                switch($i){
                    case 1:
                        if(!empty($rowset)){
                            $records['score']=$rowset[0]['score'];
                            $records['prizes']=$rowset[0]['prizes'];
                            $records['dhprizes']=$rowset[0]['dhprizes'];
                            $records['sendscore']=$rowset[0]['sendscore'];
                            $records['czscore']=$rowset[0]['czscore'];
                            $records['reg']=$rowset[0]['reg'];
                            $records['drreg']=$rowset[0]['drreg'];
                            $records['iosreg']=$rowset[0]['iosreg'];
                            $records['driosreg']=$rowset[0]['driosreg'];
                            $records['andreg']=$rowset[0]['andreg'];
                            $records['anddrreg']=$rowset[0]['anddrreg'];
                            $records['totalmoney']=$rowset[0]['totalmoney'];
                            $records['drmoney']=$rowset[0]['drmoney'];
                            $records['czcount']=$rowset[0]['czcount'];
                            $records['drcount']=$rowset[0]['drcount'];
                            $records['zsy']=$rowset[0]['zsy'];
                            $records['logincount']=$rowset[0]['logincount'];
                            $records['drlogin']=$rowset[0]['drlogin'];
                            $records['onlist']=$rowset[0]['onlist'];
                            $records['dqzx']=$rowset[0]['dqzx'];
                        }else{
                            $records="error!";
                        }
                        break;
                }
                $i++;
            }while($sth->nextRowset());
            $out=['records'=>$records];
            return json($out);
        }catch(\Exception $e){
            echo $e->getMessage();
        }
    }
}